package com.xiaoshuidi.cloud.module.member.enums.point;

import lombok.Getter;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;

/**
 * @description: 积分消费类型枚举
 * @author: neil@ixiaoshuidi.com
 * @create: 2022-12-15 15:05
 **/
@Getter
public enum PointRecordEnums {
    /**
     * 手动
     */
    HAND(0, "手动"),
    /**
     * 租金
     */
    RENT(1, "租金"),
    /**
     * 交易
     */
    TRADE(2, "交易"),
    /**
     * 大转盘
     */
    DIAL(3, "大转盘"),
    /**
     * 生日赠积分
     */
    BIRTHDAY(4, "生日"),
    /**
     * 升级赠积分
     */
    UPGRADE(5, "升级"),
    /**
     * 交易撤销
     */
    REFUND(6, "交易撤销"),
    QUESTIONNAIRE(7, "问卷调查"),
    INVITE_NEW_CUSTOMERS(8, "邀请有礼"),
    BIRTHDAY_GIFT(9, "生日积分"),
    ACTIVITIES(10, "活动报名奖励积分"),
    TOPIC(11, "发帖奖励积分"),
    MALL(12, "积分商城"),
    ACCOUNT_CONSOLIDATION(13, "账号合并");


    public Integer value;
    public String msg;

    PointRecordEnums(Integer value, String msg) {
        this.value = value;
        this.msg = msg;
    }

    public Integer value() {
        return this.value;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByKey(int key) {
        PointRecordEnums[] payArray = values();
        for (PointRecordEnums channelEnum : payArray) {
            if (channelEnum.value() == key) {
                return channelEnum.getMsg();
            }
        }
        return null;
    }


    public static List<HashMap<String, Object>> getList() {
        List<HashMap<String, Object>> list = new ArrayList<>();
        for (PointRecordEnums enums : EnumSet.allOf(PointRecordEnums.class)) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("value", enums.value);
            map.put("msg", enums.msg);
            list.add(map);
        }
        return list;
    }

    public static PointRecordEnums getPointRecordEnumsByValue(Integer value) {
        for (PointRecordEnums channelEnum : PointRecordEnums.values()) {
            if (channelEnum.value().equals(value)) {
                return channelEnum;
            }
        }
        return null;
    }
}
